package com.aaa.sbms.controller;

import com.aaa.sbms.service.DMService;
import com.aaa.sbms.util.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Map;

@RestController
@RequestMapping("dm")
public class DMController {

    @Autowired
    private DMService dmService;

    @RequestMapping("dmList")
    public  Object list(@RequestParam Map map){
        return dmService.getList(map);
    };

    @RequestMapping("checkInfo")
    public Object checkByUserId(@RequestParam Map map){
        return dmService.checkByUserId(map);
    }

    @RequestMapping("floorList")
    public Object getFloorList(@RequestParam Map map){
        return dmService.getFloor(map);
    }

    @RequestMapping("roomList")
    public Object getRoomList(@RequestParam Map map){
        return dmService.getRoom(map);
    }

    @RequestMapping("addRoomList")
    public Object addGetRoomList(@RequestParam Map map){
        return dmService.addGetRoom(map);
    }

    @RequestMapping("add")
    public Object addRoom(@RequestBody Map map, HttpSession session){
        map.put("userName", SessionUtil.getUserName());
        return dmService.addBedCount(map);
    };

    @RequestMapping("del")
    public Object delRoom(@RequestBody Map map, HttpSession session){
        map.put("userName", SessionUtil.getUserName());
        return dmService.delBedCount(map);
    };

    @RequestMapping("insert")
    public Object insert(@RequestBody Map map, HttpSession session){
        map.put("userName", SessionUtil.getUserName());
        return dmService.add(map);}

    @RequestMapping("update")
    public  Object update(@RequestBody Map map, HttpSession session){
        map.put("userName", SessionUtil.getUserName());
        return dmService.update(map);
    }

    @RequestMapping("updateIng")
    public  Object updateIng(Integer USERID){
        return dmService.updateIng(USERID);
    }

}
